import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
	selectedType: uni.getStorageSync('selectedType'),
	selectedSpec: uni.getStorageSync('selectedSpec'),
	selectedFile: uni.getStorageSync('selectedFile')
};

const mutations = {
	SET_SELECTED_TYPE: (state, selectedType) => {
		uni.setStorageSync('selectedType', selectedType);
		state.selectedType = selectedType;
	},
	SET_SELECTED_SPEC: (state, selectedSpec) => {
		uni.setStorageSync('selectedSpec', selectedSpec);
		state.selectedSpec = selectedSpec;
	},
	SET_SELECTED_FILE: (state, selectedFile) => {
		uni.setStorageSync('selectedFile', selectedFile);
		state.selectedFile = selectedFile;
	}
};

export default {
	namespaced: true,
	state,
	mutations
}
